package com.cqut.forum.entity;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * @author yangxun
 * ArticleGroup entity
 */
@Entity
@Table(name = "article_group", catalog = "forum")
public class ArticleGroup implements java.io.Serializable {

	// Fields

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Integer articleGroupId;
	private String articleGroupName;
	private Boolean articleGroupState;
	private Integer ownerId;
	private Integer articleNumber;
	private String articlePassword;
	private Boolean isPublic;
	private Integer moduleId;
	private Set<Article> articles = new HashSet<Article>(0);

	// Constructors

	/** default constructor */
	public ArticleGroup() {
	}

	/** full constructor */
	public ArticleGroup(String articleGroupName, Boolean articleGroupState,Integer moduleId,
			Integer ownerId, Integer articleNumber,String articlePassword, 
			Boolean isPublic, Set<Article> articles) {
		this.articleGroupName = articleGroupName;
		this.articleGroupState = articleGroupState;
		this.ownerId = ownerId;
		this.articleNumber = articleNumber;
		this.articles = articles;
		this.moduleId = moduleId;
		this.articlePassword = articlePassword;
		this.isPublic = isPublic;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "article_group_id", unique = true, nullable = false)
	public Integer getArticleGroupId() {
		return this.articleGroupId;
	}

	public void setArticleGroupId(Integer articleGroupId) {
		this.articleGroupId = articleGroupId;
	}

	@Column(name = "article_group_name", length = 50)
	public String getArticleGroupName() {
		return this.articleGroupName;
	}

	public void setArticleGroupName(String articleGroupName) {
		this.articleGroupName = articleGroupName;
	}

	@Column(name = "article_group_state")
	public Boolean getArticleGroupState() {
		return this.articleGroupState;
	}

	public void setArticleGroupState(Boolean articleGroupState) {
		this.articleGroupState = articleGroupState;
	}

	@Column(name = "owner_id")
	public Integer getOwnerId() {
		return this.ownerId;
	}

	public void setOwnerId(Integer ownerId) {
		this.ownerId = ownerId;
	}

	@Column(name = "article_number")
	public Integer getArticleNumber() {
		return this.articleNumber;
	}

	public void setArticleNumber(Integer articleNumber) {
		this.articleNumber = articleNumber;
	}
	
	@Column(name = "article_password")
	public String getArticlePassword() {
		return articlePassword;
	}

	public void setArticlePassword(String articlePassword) {
		this.articlePassword = articlePassword;
	}

	@Column(name = "module_id")
	public Integer getModuleId() {
		return moduleId;
	}

	public void setModuleId(Integer moduleId) {
		this.moduleId = moduleId;
	}
	
	@Column(name = "is_public")
	public Boolean getIsPublic() {
		return isPublic;
	}

	public void setIsPublic(Boolean isPublic) {
		this.isPublic = isPublic;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "articleGroup")
	public Set<Article> getArticles() {
		return this.articles;
	}

	public void setArticles(Set<Article> articles) {
		this.articles = articles;
	}

}